<!-- 联系客服 -->
<template>
  <div class="contact_container">
    <van-row type="flex" justify="center" class="contact_title">
      <van-col>
        <p class="font38">添加客服微信</p>
      </van-col>
    </van-row>
    <van-row type="flex" justify="center" class="tac">
      <van-col>
        <!-- <img src="../../assets/images/ewm.png" width="100%" alt=""> -->
        <img :src="fileUrl" width="80%" alt="">
      </van-col>
    </van-row>
    <van-row type="flex" justify="center" class="pres">
      <van-col :span="8">
        <van-button type="info" size="small" @click="download">保存图片</van-button>
      </van-col>
    </van-row>
  </div>
</template>

<script>
export default {
  data () {
    return {
      fileUrl: '',
      // fileUrl:'https://img.yzcdn.cn/vant/logo.png',
    }
  },
  methods: {
    download () {
      let self = this
      let dtask = plus.downloader.createDownload(this.fileUrl, {}, function (d, status) {
        if (status == 200) {
          plus.gallery.save(d.filename, function () {//保存到相册方法
            self.$notify({ type: 'success', message: '保存成功' });
          }, function () {
            self.$notify({ type: 'warning', message: '保存失败，请重试' });
          });
        } else {
          self.$notify({ type: 'warning', message: '下载失败' });
        }
      });
      dtask.start();
    }
  },
  async mounted () {
    //获取客服二维码
    this.fileUrl = await this.common.cashList('CUSTOMER_SRERVICE_URL')
  }
}
</script>

<style>
.contact_container {
  margin: 0, 5rem;
}
.contact_title {
  margin: 0.3rem 0;
  font-size: 0.3rem;
}
.img_box img {
  width: 100%;
}
.pres {
  padding-top: 0.4rem;
}
</style>
